package compareTest;


import epam_java.jsontest.UserTest;
import java.util.ArrayList;
import java.util.Comparator;

public class  ComparatorName <T> implements Comparator<T>{
        ArrayList<UserTest> users;

    public ComparatorName(ArrayList<UserTest> users) {
        this.users = users;
    }
    public int compare(T o1, T o2) {
       int i=0;
        if(o1 instanceof Integer&&o2 instanceof Integer){
            Integer i1=(Integer)o1;
            Integer i2=(Integer)o2;
            return (users.get(i1).getUserName().compareTo(users.get(i2).getUserName()));
        }
       return i;
    }
}